﻿using IdentityModel;
using IdentityServer4.Models;
using IdentityServer4.Test;

namespace SJ.Platform.IdentityServer
{
    public class InMemoryConfiguration
    {
        public static IEnumerable<IdentityResource> IdentityResources =>
         new List<IdentityResource>
         {
            new IdentityResources.OpenId(),
            new IdentityResources.Profile()
         };


        public static IEnumerable<ApiScope> ApiScopes =>
            new ApiScope[]
            {
                new ApiScope("SJ.Platform.Api")
                {
                    UserClaims = {"UserId", "RealName", "OrgId", "OrgName", "Sex", "Birthday", "IsUsed" }
                },
                new ApiScope("SJ.Platform.LogApi"),
                new ApiScope("SJ.Platform.StatisticsApi")
            };

        public static IEnumerable<Client> Clients =>
            new List<Client>
            {
                new Client
                {
                    ClientId = "SJ.Platform.Api",
                    // 账号密码方式
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    // 用于身份验证的密钥
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())  //secret加密密钥 Sha256加密方式
                    },
                    // 客户端有权访问的范围
                    AllowedScopes = { "SJ.Platform.Api","SJ.Platform.LogApi" },
                    AccessTokenLifetime = 28800 //过期时间，单位是秒，默认8个小时
                },
                 new Client
                {
                    ClientId = "SJ.Platform.LogApi",
                    // 账号密码方式
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    // 用于身份验证的密钥
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())  //secret加密密钥 Sha256加密方式
                    },
                    // 客户端有权访问的范围
                    AllowedScopes = { "SJ.Platform.LogApi" },
                    AccessTokenLifetime = 28800 //过期时间，默认3600秒
                },
                  new Client
                {
                    ClientId = "SJ.Platform.StatisticsApi",
                    // 账号密码方式
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    // 用于身份验证的密钥
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())  //secret加密密钥 Sha256加密方式
                    },
                    // 客户端有权访问的范围
                    AllowedScopes = { "SJ.Platform.StatisticsApi" },
                    AccessTokenLifetime = 28800 //过期时间，默认3600秒
                }
            };
    }
}
